const AutorunSource = GObject.registerClass(
class AutorunSource extends MessageTray.Source {
- _init(manager, mount, apps) {
- super._init(mount.get_name());
+ constructor(manager, mount, apps) {
+ super({
+ title: mount.get_name(),
+ icon: mount.get_icon(),
+ });
this._manager = manager;
this.mount = mount;
this.showNotification(this._notification);
}
- get icon() {
- return this.mount.get_icon();
- }
-
_createPolicy() {
return new MessageTray.NotificationApplicationPolicy('org.gnome.Nautilus');
}
}
_showNotification(requestId, connection, settingName, hints, flags) {
- let source = new MessageTray.Source(_('Network Manager'), 'network-transmit-receive');
+ const source = new MessageTray.Source({
+ title: _('Network Manager'),
+ iconName: 'network-transmit-receive',
+ });
source.policy = new MessageTray.NotificationApplicationPolicy('gnome-network-panel');
let title, body;
this._contact = contact;
this._client = client;
- super._init(contact.get_alias());
+ super._init();
this._pendingMessages = [];
'notify::alias', this._updateAlias.bind(this),
'notify::avatar-file', this._updateAvatarIcon.bind(this), this);
+ this._updateAlias();
+ this._updateAvatarIcon();
// Add ourselves as a source.
Main.messageTray.add(this);
if (oldAlias === newAlias)
return;
- this.setTitle(newAlias);
+ this.title = newAlias;
if (this._notification)
this._notification.appendAliasChange(oldAlias, newAlias);
}
- get icon() {
+ _updateAvatarIcon() {
let file = this._contact.get_avatar_file();
- if (file)
- return new Gio.FileIcon({file});
- else
- return new Gio.ThemedIcon({name: 'avatar-default'});
- }
+ if (file) {
+ if (this.icon instanceof Gio.FileIcon)
+ this.icon.file = file;
+ else
+ this.icon = new Gio.FileIcon({file});
+ } else if (!(this.icon instanceof Gio.ThemedIcon)) {
+ this.iconName = 'avatar-default';
+ }
- _updateAvatarIcon() {
- this.notify('icon');
- if (this._notification) {
+ if (this._notification && this.icon !== this._notification.gicon) {
this._notification.update(
this._notification.title,
this._notification.bannerBodyText,
if (!this._app)
this._app = appSys.lookup_app('com.mattjakeman.ExtensionManager.desktop');
- super._init(this._app.get_name());
- }
-
- get icon() {
- return this._app.app_info.get_icon();
+ super._init({
+ title: this._app.get_name(),
+ icon: this._app.get_icon(),
+ });
}
_createPolicy() {
'notification-show': {param_types: [Notification.$gtype]},
},
}, class Source extends GObject.Object {
- _init(title, iconName) {
- super._init({title});
-
- this.icon = new Gio.ThemedIcon({name: iconName});
+ constructor(params) {
+ super(params);
this.notifications = [];
: PrivacyScope.USER;
}
- setTitle(newTitle) {
- if (this.title === newTitle)
- return;
-
- this.title = newTitle;
- this.notify('title');
- }
-
createBanner(notification) {
return new NotificationBanner(notification);
}
export const SystemNotificationSource = GObject.registerClass(
class SystemNotificationSource extends Source {
- _init() {
- super._init(_('System Information'), 'dialog-information-symbolic');
+ constructor() {
+ super({
+ title: _('System Information'),
+ iconName: 'dialog-information-symbolic',
+ });
}
open() {
this.pid = pid;
this.initialTitle = title;
this.app = this._getApp(appId);
+ this._appIcon = null;
// Use app name as title if available, instead of whatever is provided
// through libnotify (usually garbage)
- super._init(this.app ? this.app.get_name() : title);
+ super._init({
+ title: this.app?.get_name() ?? title,
+ });
if (sender) {
this._nameWatcherId = Gio.DBus.session.watch_name(sender,
this.notify('icon');
}
+
let tracker = Shell.WindowTracker.get_default();
if (notification.resident && this.app && tracker.focus_app === this.app)
this.pushNotification(notification);
}
get icon() {
- if (this.app)
- return this.app.get_icon();
- else if (this._appIcon)
- return this._appIcon;
- else
- return null;
+ return this.app?.get_icon() ?? this._appIcon;
}
});
this._app = app;
this._objectPath = objectPath;
- super._init(app.get_name());
+ super._init({
+ title: app.get_name(),
+ icon: app.get_icon(),
+ });
this._notifications = {};
this._notificationPending = false;
}
- get icon() {
- return this._app.get_icon();
- }
-
_createPolicy() {
return new MessageTray.NotificationApplicationPolicy(this._appId);
}
// Show a notification.
const file = Gio.file_new_for_path(this._screencastPath);
- const source = new MessageTray.Source(
+ const source = new MessageTray.Source({
// Translators: notification source name.
- _('Screenshot'),
- 'screencast-recorded-symbolic'
- );
+ title: _('Screenshot'),
+ iconName: 'screencast-recorded-symbolic',
+ });
const notification = new MessageTray.Notification(
source,
title,
);
// Show a notification.
- const source = new MessageTray.Source(
+ const source = new MessageTray.Source({
// Translators: notification source name.
- _('Screenshot'),
- 'screenshot-recorded-symbolic'
- );
+ title: _('Screenshot'),
+ iconName: 'screenshot-recorded-symbolic',
+ });
const notification = new MessageTray.Notification(
source,
// Translators: notification title.
const ShellUnmountNotifier = GObject.registerClass(
class ShellUnmountNotifier extends MessageTray.Source {
- _init() {
- super._init('', 'media-removable');
+ constructor() {
+ super({
+ iconName: 'media-removable',
+ });
this._notification = null;
Main.messageTray.add(this);
_onActivationFailed() {
this._notification?.destroy();
- const source = new MessageTray.Source(
- _('Network Manager'), 'network-error-symbolic');
+ const source = new MessageTray.Source({
+ title: _('Network Manager'),
+ iconName: 'network-error-symbolic',
+ });
source.policy =
new MessageTray.NotificationApplicationPolicy('gnome-network-panel');
_ensureSource() {
if (!this._source) {
- this._source = new MessageTray.Source(_('Thunderbolt'),
- 'thunderbolt-symbolic');
+ this._source = new MessageTray.Source({
+ title: _('Thunderbolt'),
+ iconName: 'thunderbolt-symbolic',
+ });
this._source.connect('destroy', () => (this._source = null));
Main.messageTray.add(this._source);
this._window = window;
this._app = app;
- super._init(app.get_name());
+ super._init({
+ title: this._app.get_name(),
+ icon: this._app.get_icon(),
+ });
this._window.connectObject(
'notify::demands-attention', this._sync.bind(this),
}
}
- get icon() {
- return this._app.get_icon();
- }
-
destroy(params) {
this._window.disconnectObject(this);